//
//  WCNGuideVC.m
//  WCN
//
//  Created by 杨鑫 on 15/5/31.
//  Copyright (c) 2015年 ShanghaiCize Trade And Business Co., Ltd. All rights reserved.
//

#import "WCNGuideVC.h"
//
#import "Macros.h"
#import "Constants.h"

@interface WCNGuideVC () <UIScrollViewDelegate>

@property (weak, nonatomic) IBOutlet UIPageControl *pageControl;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *pageHeight;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *pageWidth;

@end

@implementation WCNGuideVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.pageWidth.constant = kScreenWidth;
    self.pageHeight.constant = kScreenHeight;
}

#pragma mark - Nib Targets

- (IBAction)skipBtnTap:(id)sender {
    __weak typeof(self) weakSelf = self;
    self.vc.view.transform = CGAffineTransformMakeScale(.8, .8);
    
    [UIView animateWithDuration:.5 animations:^{
        weakSelf.view.frame = CGRectMake(-kScreenWidth, 0, kScreenWidth, kScreenHeight);
    } completion:^(BOOL fnished){
        [[NSNotificationCenter defaultCenter] postNotificationName:GuideViewCloseNotification object:nil];
    }];
    
    [UIView animateWithDuration:.5 delay:.1 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        weakSelf.vc.view.transform = CGAffineTransformIdentity;
    } completion:nil];
}

#pragma mark - UIScrollViewDelegate

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    //current page
    self.pageControl.currentPage = scrollView.contentOffset.x/kScreenWidth;
}

@end
